bitkeeper revision 1.1709.1.7 (42af1a85T412eQfXEME3Z3XLDYOmWg)
authordjm@kirby.fc.hp.com <djm@kirby.fc.hp.com>
Tue, 14 Jun 2005 17:57:25 +0000 (17:57 +0000)
committerdjm@kirby.fc.hp.com <djm@kirby.fc.hp.com>
Tue, 14 Jun 2005 17:57:25 +0000 (17:57 +0000)
XEN/VTI utilizes a PMT table to describe physical->machine
mapping info, instead of 3 level page tables from Linux.
Attached patch adds some necessary macro/interface/definitions
about that structure.  Some stuff is added to public directory,
because control panel needs to use those info to construct domain.

Signed-off-by Kevin Tian <Kevin.tian@intel.com>

xen/arch/ia64/xenmem.c
xen/include/asm-ia64/domain.h
xen/include/asm-ia64/mm.h
xen/include/asm-ia64/vmx_vpd.h
xen/include/public/arch-ia64.h

index 3a749840a0f7536fddb0252a8536e7f589a0369f..088611b22acc845a22c7236385b599567bd9afc0 100644 (file)
@@ -52,7 +52,7 @@ paging_init (void)
                panic("Not enough memory to bootstrap Xen.\n");
 
        printk("machine to physical table: 0x%lx\n", (u64)mpt_table);
-       memset(mpt_table, 0x55, mpt_table_size);
+       memset(mpt_table, INVALID_M2P_ENTRY, mpt_table_size);
 
        /* Any more setup here? On VMX enabled platform,
         * there's no need to keep guest linear pg table,
index 83d2542a73a5f402438c09670b8e145fc7b11150..a4caf018b6f495faeb08f76856ed0c465417ffc3 100644 (file)
@@ -6,6 +6,7 @@
 #include <asm/vmx_vpd.h>
 #include <asm/vmmu.h>
 #include <asm/regionreg.h>
+#include <public/arch-ia64.h>
 #endif // CONFIG_VTI
 #include <xen/list.h>
 
@@ -33,7 +34,15 @@ struct arch_domain {
     int imp_va_msb;
     ia64_rr emul_phy_rr0;
     ia64_rr emul_phy_rr4;
-    u64 *pmt;  /* physical to machine table */
+    unsigned long *pmt;        /* physical to machine table */
+    /*
+     * max_pfn is the maximum page frame in guest physical space, including
+     * inter-middle I/O ranges and memory holes. This is different with
+     * max_pages in domain struct, which indicates maximum memory size
+     */
+    unsigned long max_pfn;
+    unsigned int section_nr;
+    mm_section_t *sections;    /* Describe memory hole except for Dom0 */
 #endif  //CONFIG_VTI
     u64 xen_vastart;
     u64 xen_vaend;
index c6d127acdb839d550e256840ec85fa686b7bac29..c84a7c781ab8b1fc5e289dd058e7e9748fce5fcd 100644 (file)
@@ -375,17 +375,40 @@ extern unsigned long *mpt_table;
 #undef machine_to_phys_mapping
 #define machine_to_phys_mapping        mpt_table
 
+#define INVALID_M2P_ENTRY        (~0U)
+#define VALID_M2P(_e)            (!((_e) & (1U<<63)))
+#define IS_INVALID_M2P_ENTRY(_e) (!VALID_M2P(_e))
 /* If pmt table is provided by control pannel later, we need __get_user
 * here. However if it's allocated by HV, we should access it directly
 */
-#define phys_to_machine_mapping(d, gpfn)       \
-    ((d) == dom0 ? gpfn : (d)->arch.pmt[(gpfn)])
+#define phys_to_machine_mapping(d, gpfn)                       \
+    ((d) == dom0 ? gpfn :                                      \
+       (gpfn <= d->arch.max_pfn ? (d)->arch.pmt[(gpfn)] :      \
+               INVALID_MFN))
 
 #define __mfn_to_gpfn(_d, mfn)                 \
     machine_to_phys_mapping[(mfn)]
 
 #define __gpfn_to_mfn(_d, gpfn)                        \
     phys_to_machine_mapping((_d), (gpfn))
+
+#define __gpfn_invalid(_d, gpfn)                       \
+       (__gpfn_to_mfn((_d), (gpfn)) & GPFN_INV_MASK)
+
+#define __gpfn_valid(_d, gpfn) !__gpfn_invalid(_d, gpfn)
+
+/* Return I/O type if trye */
+#define __gpfn_is_io(_d, gpfn)                         \
+       (__gpfn_valid(_d, gpfn) ?                       \
+       (__gpfn_to_mfn((_d), (gpfn)) & GPFN_IO_MASK) : 0)
+
+#define __gpfn_is_mem(_d, gpfn)                                \
+       (__gpfn_valid(_d, gpfn) ?                       \
+       ((__gpfn_to_mfn((_d), (gpfn)) & GPFN_IO_MASK) == GPFN_MEM) : 0)
+
+
+#define __gpa_to_mpa(_d, gpa)   \
+    ((__gpfn_to_mfn((_d),(gpa)>>PAGE_SHIFT)<<PAGE_SHIFT)|((gpa)&~PAGE_MASK))
 #endif // CONFIG_VTI
 
 #endif /* __ASM_IA64_MM_H__ */
index 78149ba31f21cbde1d60341eaf9b1b0bbfeccf36..be29ed1d47bb349d0d3e588ffc087c49cc0e845e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <asm/vtm.h>
 #include <asm/vmx_platform.h>
+#include <public/arch-ia64.h>
 
 #define VPD_SHIFT      17      /* 128K requirement */
 #define VPD_SIZE       (1 << VPD_SHIFT)
index 6f0c499531aa50c53831db0ba2e752a582df5970..53a41016414c37983ab44d36d10b88ffdcbcf47e 100644 (file)
 /* NB. Both the following are 64 bits each. */
 typedef unsigned long memory_t;   /* Full-sized pointer/address/memory-size. */
 
+#define MAX_NR_SECTION  32  // at most 32 memory holes
+typedef struct {
+    unsigned long      start;  /* start of memory hole */
+    unsigned long      end;    /* end of memory hole */
+} mm_section_t;
+
+typedef struct {
+    unsigned long      mfn : 56;
+    unsigned long      type: 8;
+} pmt_entry_t;
+
+#define GPFN_MEM               (0UL << 56)     /* Guest pfn is normal mem */
+#define GPFN_FRAME_BUFFER      (1UL << 56)     /* VGA framebuffer */
+#define GPFN_LOW_MMIO          (2UL << 56)     /* Low MMIO range */
+#define GPFN_PIB               (3UL << 56)     /* PIB base */
+#define GPFN_IOSAPIC           (4UL << 56)     /* IOSAPIC base */
+#define GPFN_LEGACY_IO         (5UL << 56)     /* Legacy I/O base */
+#define GPFN_GFW               (6UL << 56)     /* Guest Firmware */
+#define GPFN_HIGH_MMIO         (7UL << 56)     /* High MMIO range */
+
+#define GPFN_IO_MASK           (7UL << 56)     /* Guest pfn is I/O type */
+#define GPFN_INV_MASK          (31UL << 59)    /* Guest pfn is invalid */
+
+#define INVALID_MFN              (~0UL)
+
+
 typedef struct
 {
 } PACKED cpu_user_regs;